//
//  CZUser.swift
//  SinaBlog
//
//  Created by 李超 on 16/3/24.
//  Copyright © 2016年 lichao. All rights reserved.
//

import UIKit

class CZUser: NSObject {
    /// 昵称
    var screen_name:String?
    /// 头像地址
    var profile_image_url:String?
    /// 是否认证
    var verified:Bool = false
    var verifiedImage:UIImage?
    /// 认证类型
    var verified_type: Int = -1{
        didSet{
            switch verified_type{
            case 0:
                verifiedImage = UIImage(named: "avatar_vip")
            case 2,3,5:
                verifiedImage = UIImage(named: "avatar_enterprise_vip")
            case 220:
                verifiedImage = UIImage(named: "avatar_grassroot")
            default: break                
            }
         
        }
        
    }
    /// 会员等级图片
    var mbrankImage:UIImage?
    /// 会员等级
    var mbrank: Int = 0{
        didSet{
            if mbrank>0 && mbrank<7{
                mbrankImage = UIImage(named: "common_icon_membership_level\(mbrank)")
            }else{
                mbrankImage = nil
            }
            
        }
    }
    //字典转模型的构造方法
    init(dict:[String : AnyObject]){
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    //处理键值比不匹配的问题
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
    }
    //重写description属性，属于计算型属性，可以省略get
    override var description:String{
        let keys = ["screen_name","profile_image_url","verified","verified_type","mbrank"]
        return dictionaryWithValuesForKeys(keys).description
    }
    

}
